// pages/ck_qs/ck_qs.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  ht_cz1:function(e){
    var that = this;
    // that.setData({
    //   yc_s:"display:block"
    // })
    
    var he_id = e.currentTarget.dataset.id; 
    wx.showModal({
      title: '温馨提示',
      content: '是否撤回合同',
      success (res) {
        if (res.confirm) {
          wx.request({
            url: app.globalData.url_l + 'api/member/hetong_de',
            method: 'post',
            data:{
                uid:app.globalData.uid,
                id:he_id
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              console.log(res)
              if(res.data.code==1){
                    that.setData({
                        yc_s:"display:none"
                      })
                      wx.showToast({
                        title: '撤回成功！',
                        icon: 'success',
                        duration: 1000,
                        success:function(){
                          console.log('haha');
                          setTimeout(function () {
                            //要延时执行的代码
                            wx.switchTab({
                              url: '../hetong/hetong'
                            })
                          }, 1000) //延迟时间
                        }
                      })
              }else{
                that.setData({
                  yc_s:"display:none"
                })
                wx.showToast({
                  title: '撤回失败！',
                  icon: 'none',
                  duration: 2000
                })
              }
              
            }
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  zhidao:function(e){
    var that = this;
   
   
  },
  ht_cz3:function(e){
    var ht_id = e.currentTarget.dataset.id; 
   wx.navigateTo({
     url: '../qianshu1/qianshu1?ht_id='+ht_id,
   })
  },
  // gr_xx:function(e){
  //   var gr_id = e.currentTarget.dataset.id; 
  //   wx.navigateTo({
  //     url: '../gr_xx1/gr_xx1?gr_id='+gr_id,
  //   })
  // },
  ht_cz2:function(e){
    var ht_id = e.currentTarget.dataset.id; 
    console.log(ht_id)
    wx.navigateTo({
      url: '../hetong_xq/hetong_xq?ht_id='+ht_id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    // var he_id = options.he_id;
    // var type = options.type;
      that.setData({
        type:app.globalData.type11
      })
    wx.request({
      url: app.globalData.url_l + 'api/member/hetong_xiang',
      method: 'post',
      data:{
          uid:app.globalData.uid,
          id:app.globalData.qs_ht
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        for(var i=0;i<res.data.ht_user.length;i++){
          if(app.globalData.uid==res.data.ht_user[i].uid){
            that.setData({
              sign_status:res.data.ht_user[i].sign_status
            })
          }
        }
        that.setData({
          hetongid:app.globalData.uid,
          faqi_ht:res.data.hetong,
          qshu_f:res.data.ht_user
        })
        
      }
    })
  },
  tiaozhuan:function(e){
     var wbl = e.currentTarget.dataset.id;
     wx.navigateTo({
      url: '../ganggao_x1/ganggao_x1?nei='+wbl,
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})